const {User} = require('../../model/user')

module.exports = async (req,res) => {

    req.app.locals.currentLink = 'user'
    
    // 页码
    let page = req.query.page || 1;
    // 每页条数
    let pageSize = 3
    // 数据总数
    let totle = await User.countDocuments({})
    // 总页数
    let pageNum = Math.ceil(totle / pageSize) 

    let users = await User.find({}).skip((page - 1) * pageSize).limit(pageSize)

    res.render('../views/admin/user',{
        username:req.session.username,
        users,
        totle,
        pageNum,
        page,
    })
}
